package com.biz.primus.ms.oms.trans;

import com.biz.primus.model.oms.vo.OmsItemVo;
import com.biz.primus.ms.base.service.AbstractBaseService;
import com.biz.primus.ms.oms.dao.po.OmsOrder;
import com.biz.primus.ms.oms.dao.po.OmsOrderItem;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author yanweijin
 * @date 2017/11/17
 */
@Component
public class OrderItemListConverter extends AbstractBaseService {


	@Autowired
	private OrderItemConverter itemConverter;

	public List<OmsOrderItem> toPoList(List<OmsItemVo> vos, OmsOrder omsOrder) {
		List<OmsOrderItem> result = Lists.newArrayList();
		vos.stream().parallel().map(vo -> {
			/**
			 * 如果有组合商品,要在这里拆分 TODO
			 */
			OmsOrderItem item = itemConverter.vo2po(vo,omsOrder);
			return Lists.newArrayList(item);
		}).collect(Collectors.toList()).forEach(result::addAll);
		return result;
	}




}
